<?php


class Model_Products_Catemapping extends Zend_Db_Table_Abstract {

	protected $_name = 'products_v1_category_mapping';
	
	public function getCatemapping( $idMapping){
		
		$row = $this->fetchRow("`id_mapping` = ". $idMapping);
		if(!$row) return false;
		return $row->toArray();		
		
		}
		
	public function addCatemapping( $aposCate1 , $aposCate2 , $aposCate3 , $idCatePhone , $idCateLove , $idCateOnlineorder){
		
		$data = array(
			
         "apos_cate_1" =>  $aposCate1 ,
         "apos_cate_2" =>  $aposCate2 ,
         "apos_cate_3" =>  $aposCate3 ,
         "id_cate_phone" =>  $idCatePhone ,
         "id_cate_love" =>  $idCateLove ,
         "id_cate_onlineorder" =>  $idCateOnlineorder 
	
			);
		$this->insert($data);
		
		}
		
	public function updateCatemapping(  $idMapping ,  $aposCate1 , $aposCate2 , $aposCate3 , $idCatePhone , $idCateLove , $idCateOnlineorder){
		$data = array(
			
         "apos_cate_1" =>  $aposCate1 ,
         "apos_cate_2" =>  $aposCate2 ,
         "apos_cate_3" =>  $aposCate3 ,
         "id_cate_phone" =>  $idCatePhone ,
         "id_cate_love" =>  $idCateLove ,
         "id_cate_onlineorder" =>  $idCateOnlineorder 
	
			);
			
		$this->update($data,"`id_mapping` = ". $idMapping);
		}
		
	public function deleteCatemapping( $idMapping){
		
		$this->delete("`id_mapping` = ". $idMapping);
		
		}	
	
	public function listAll(){
		
		$rows =$this->fetchAll("1","id_mapping DESC ");
		if(!$rows) return false;
		return $rows->toArray();			
		
		}	
		
	public function getOrderCategory($aposCate1,$aposCate2){
		
		$whereStr = "`apos_cate_1` LIKE '{$aposCate1}' AND `apos_cate_2` LIKE '{$aposCate2}'";
		
		$row = $this->fetchRow($whereStr);
		if(!$row) return false;
		$row = $row->toArray();
		return $row['id_cate_onlineorder'];
	}	
	
}


?>